import unittest
from player import Player
from enemy import Enemy
from tmap import Map

class MapTest(unittest.TestCase):
    def setUp(self):
        self.ppl=Player()
        self.enemy=Enemy()
        self.newmap=Map([[0,0,0,self.ppl],
                    [0,0,0,0],
                    [0,0,0,0],
                    [self.enemy,0,0,0]])
    def test_Hero(self):                                            #..test attack()..#
        print 'start test Hero.attack()'                            #
        self.assertEqual(self.ppl.hp,10)                            #
        self.assertEqual(self.ppl.atk,10)                           #
        self.assertNotEqual(self.ppl.hp,100)                        #
        for i in range(0,5):                                        #..attck 5 times..#
            self.ppl.attack(self.enemy)                             #
            print 'attack'                                          #
        self.assertNotEqual(self.enemy.hp,100)                      #
        self.assertEqual(self.enemy.isOver(),True)                  #..attack() over..#
        print 'attack over()'
    def test_Map(self):
        print 'start test fly()'
        self.assertEqual(self.newmap.getPosition(self.ppl),(0,3))   #..start testing get_position()..#
        self.assertEqual(self.newmap.getPosition(self.enemy),(3,0)) #..get_position() over..
        self.assertEqual(self.newmap.fly(self.ppl,2,2),(2,2))       #..start testing fly()..
        self.assertEqual(self.newmap.fly(self.enemy,55,55),False)   #..
        self.assertEqual(self.newmap.fly(self.ppl,55,55),False)     #..fly() over..#
        print 'fly test over'
        
if __name__ == '__main__':
    unittest.main()
